package prototipo.server.logic.transaction;

import java.util.GregorianCalendar;

import prototipo.server.logic.exception.ExceptionLogic;
import prototipo.server.logic.util.Money;

public class PaymentP extends Payment implements PaymentPIF{

	private long number;
	private String sender;
	private GregorianCalendar dateDue;

	public PaymentP(Money value, String sender, GregorianCalendar dateDue) throws ExceptionLogic {
		super(value,false);
		this.setSender(sender);
		this.setDateDue(dateDue);
	}

	/**
	 * @return the number
	 */
	public long getNumber() {
		return number;
	}

	/**
	 * @param number
	 *            the number to set
	 * @throws ExceptionLogic
	 */
	public void setNumber(long number) throws ExceptionLogic {
		if (number < 0)
			throw new ExceptionLogic("Numero de nota promissoria negativo.",
					new Throwable("Number is negative."));
		this.number = number;
	}

	/**
	 * @return the sender
	 */
	public String getSender() {
		return sender;
	}

	/**
	 * @param sender
	 *            the sender to set
	 */
	public void setSender(String sender) throws ExceptionLogic {
		if (sender == null || sender.equals(""))
			throw new ExceptionLogic("Emissor vazio.", new Throwable(
					"String sender is null."));
		this.sender = sender;
	}

	/**
	 * @return the dateDue
	 */
	public GregorianCalendar getDateDue() {
		return dateDue;
	}

	/**
	 * @param dateDue
	 *            the dateDue to set
	 * @throws ExceptionLogic
	 */
	public void setDateDue(GregorianCalendar dateDue) throws ExceptionLogic {
		if (dateDue == null)
			throw new ExceptionLogic("Data de vencimento vazia.",
					new Throwable("Calender is null."));
		this.dateDue = dateDue;
	}

}
